object ScoreStatsDemo extends App {
  val scores: List[Int] = List(75, 82, 90, 65, 88, 79, 55, 92)
  var totalSum = 0
  for (i <- 0 until scores.length) {
    totalSum += scores(i)
  }
  val averageScore = if (scores.nonEmpty) {
    totalSum.toDouble / scores.length
  } else 0.0
  println(f"平均分：$averageScore%.2f")
  println("\n分数段统计：")
  val scoreRanges = List((0, 60), (60, 80), (80, 100))
  for ((min, max) <- scoreRanges) {
    var count = 0
    for (score <- scores) {
      if (score > min && score <= max) {
        count += 1
      }
    }
    println(s"分数段 $min-$max：$count 人")
  }
}
